package com.macbulldev.poc.testgin.service;

import java.util.List;

import jxl.common.Logger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;

@Service("emailService")
@Configurable
public class EmailService 
{
	
	private static final Logger LOGGER = Logger.getLogger(EmailService.class);
	@Autowired
	@Qualifier("mailSender")
	private MailSender mailSender;
	
	@Autowired
	@Qualifier("emailMessageTemplate")
	private SimpleMailMessage emailMessageTemplate;
	

	public void sendEmail(String[] recipient, String subject, String message)
	{

			emailMessageTemplate.setTo(recipient);
			emailMessageTemplate.setSubject(subject);
			emailMessageTemplate.setText(message);
			
			mailSender.send(emailMessageTemplate);
			LOGGER.debug("sending complete");
		

		
		
//	            
//	                    
//	                    MimeMessage message = new MimeMessage( mailSession );
//	                    message.setSubject( theForm.getSubject() );
//	                    message.setContent( theForm.getEmailMessage(), "text/plain" );
//	                    message.setFrom( new InternetAddress( theForm.getFromEmail() ) );
//	                    message.addRecipient( Message.RecipientType.TO, new InternetAddress( toEmail ) );
//	                    
		
	}

	public MailSender getMailSender() {
		return mailSender;
	}

	public void setMailSender(MailSender mailSender) {
		this.mailSender = mailSender;
	}

	public SimpleMailMessage getEmailMessageTemplate() {
		return emailMessageTemplate;
	}

	public void setEmailMessageTemplate(SimpleMailMessage emailMessageTemplate) {
		this.emailMessageTemplate = emailMessageTemplate;
	}
	
	
	
	
}
